package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleHomeQueryDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文章控制器
 *
 * @author liudo
 * @version 1.0
 * @project heima-leadnews
 * @date 2023/11/4 09:40:10
 */
@RestController
@RequestMapping("/api/v1/article")
@RequiredArgsConstructor
public class ArticleController {

    private final ApArticleService apArticleService;

    /**
     * 加载首屏信息
     *
     * @param articleHomeQueryDto 文章主页查询dto
     * @return {@link ResponseResult}<{@link List}<{@link ApArticle}>>
     */
    @PostMapping("/load")
    public ResponseResult<List<ApArticle>> load(@RequestBody ArticleHomeQueryDto articleHomeQueryDto) {
        List<ApArticle> articleList = apArticleService.load(articleHomeQueryDto);
        return ResponseResult.okResult(articleList);
    }

}
